package com.dminvoicemanager;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DM_DatabaseHandler extends SQLiteOpenHelper{
	 // Database Version
    private static final int DATABASE_VERSION = 5;
    // Database Name
    private static String DBNAME = "dminvoicemanager.db";
 // Table  Name
    private static final String SERVER_DB_LIST = "serverdb";
    

	 public DM_DatabaseHandler(Context context) {
	        super(context, DBNAME, null, DATABASE_VERSION);
	    }
	 
	@Override
	public void onCreate(SQLiteDatabase arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		
	}
	 public List<String> getAllLabels(){
	    	List<String> labels = new ArrayList<String>();
	    	
	        // Select All Query
	        String selectQuery = "SELECT  * FROM " + SERVER_DB_LIST;
	     
	        SQLiteDatabase db = this.getReadableDatabase();
	        Cursor cursor = db.rawQuery(selectQuery, null);
	     
	        // looping through all rows and adding to list
	        if (cursor.moveToFirst()) {
	            do {
	            	labels.add(cursor.getString(1));
	            } while (cursor.moveToNext());
	        }
	        
	        // closing connection
	        cursor.close();
	        db.close();
	    	
	    	// returning lables
	    	return labels;
	    }
}
